package com.aduerr.v1shouyin.view;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.aduerr.v1shouyin.R;


public class SignInDialog extends Dialog {

    /**
     * 上下文对象 *
     */
    Activity context;

    private View.OnClickListener cancleClickListener;
    private ImageView cancle;
    private TextView jiesuan_acount;
    private TextView jiesuan_bank;
    private TextView jiesuan_bank_number;
    private LinearLayout power;

    public SignInDialog(Activity context) {
        super(context);
        this.context = context;
    }

    public SignInDialog(Activity context, int theme,
                        View.OnClickListener cancleClickListener) {
        super(context, theme);
        this.context = context;
        this.cancleClickListener = cancleClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 指定布局
        this.setContentView(R.layout.signin_dialog);
        /*
         * 获取圣诞框的窗口对象及参数对象以修改对话框的布局设置, 可以直接调用getWindow(),表示获得这个Activity的Window
         * 对象,这样这可以以同样的方式改变这个Activity的属性.
         */
        Window dialogWindow = this.getWindow();
        WindowManager m = context.getWindowManager();
        Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
        WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
//         p.height = (int) (d.getHeight() * 0.3); // 高度设置为屏幕的0.6
        p.width = (int) (d.getWidth() * 0.8); // 宽度设置为屏幕的0.8
        dialogWindow.setAttributes(p);

        // 根据id在布局中找到控件对象
        cancle = (ImageView) this.findViewById(R.id.iv_cancle);
        jiesuan_acount = (TextView) this.findViewById(R.id.jiesuan_acount);
        jiesuan_bank = (TextView) this.findViewById(R.id.jiesuan_bank);
        jiesuan_bank_number = (TextView) this.findViewById(R.id.jiesuan_bank_number);
        power = (LinearLayout) this.findViewById(R.id.ll_power);
        // 为按钮绑定点击事件监听器
        cancle.setOnClickListener(cancleClickListener);

        this.setCancelable(false);
    }

    public void setText(String jiesuanacount, String jiesuanbank,
                        String jiesuanbanknumber) {

        jiesuan_acount.setText("结算账户 :" + jiesuanacount);
        jiesuan_bank.setText("结算卡号 :" + jiesuanbank + "");
        jiesuan_bank_number.setText("结算银行 :" + jiesuanbanknumber);
    }

    public void setvisbility() {
        power.setVisibility(View.GONE);
    }


}
